import "dotenv/config";
import inquirer from "inquirer";

import { questions } from "./questions/refresh";
import { refreshToken } from "./utils/refreshToken";
import { processToken } from "./utils/processToken";
import { readFileByType } from "./utils/util";

inquirer.prompt(questions).then(async (answers) => {
  console.log(answers);
  if (answers.isRefresh) {
    const refresh_token = readFileByType("refresh_token")
    const res = await refreshToken(refresh_token);
    if (res) {
      processToken(res);
    }
  }
});
